﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:fo="http://www.w3.org/1999/XSL/Format" 
	xmlns:hbm="urn:nhibernate-mapping-2.2"
	xmlns:msxsl="urn:schemas-microsoft-com:xslt"
	xmlns:helper="urn:helper">
	<xsl:include href="metadata.xslt"/>
	<xsl:include href="mappings_dto.xslt"/>
	<xsl:include href="query.xslt"/>	
	<xsl:output method="text" encoding="UTF-8"/>
	
	<xsl:template match="*" priority="-1"></xsl:template>

	<!-- корневой элемент, отсюда вызываются все шаблоны -->
	<xsl:template match="hbm:hibernate-mapping">
		<xsl:text>using System;
using System.Collections;
using System.Collections.Generic;
using Iesi.Collections.Generic;
using System.Linq;

using NHibernate;

using </xsl:text>
	<xsl:value-of select="@namespace"/>
	<xsl:text>.MetadataInfo;

namespace </xsl:text><xsl:value-of select="@namespace"/><xsl:text>
{
</xsl:text>
		<xsl:apply-templates select="*">
			<xsl:with-param name="dto">false</xsl:with-param>
		</xsl:apply-templates>
		<xsl:if test="$use-dto='true'">
			<xsl:apply-templates select="*">
				<xsl:with-param name="dto">true</xsl:with-param>
			</xsl:apply-templates>
		</xsl:if>
		<xsl:apply-templates select="*" mode="metadata"/>
		<xsl:apply-templates select="*" mode="query"/>
		<xsl:text>
}</xsl:text>
	</xsl:template>

</xsl:stylesheet>
